package lg.minecraft.plugin.library.item.builder;

import lg.minecraft.plugin.library.item.ItemProperties;
import org.bukkit.inventory.ItemStack;

import java.util.Map;

/**
 * @author langle__
 * @version 1.0
 */
public class DynamicItemBuilder extends PlaceholderItemBuilder {

    private final ItemProperties alternateProperties;

    public DynamicItemBuilder(ItemProperties primaryProperties, ItemProperties alternateProperties) {
        super(primaryProperties);
        this.alternateProperties = alternateProperties;
    }

    public DynamicItemBuilder(ItemProperties properties) {
        this(properties, properties);
    }

    @Override
    protected ItemStack build(Map<String, String> map, Object... args) {
        boolean flag = (boolean) args[0];
        ItemProperties selectedProperties = flag ? properties : alternateProperties;
        return PlaceholderItemBuilder.buildBasicItem(selectedProperties, map);
    }

    public ItemStack build(Map<String, String> map, boolean useAlternate) {
        return build(map, (Object) useAlternate);
    }

    @Override
    public ItemStack build(Map<String, String> map) {
        return build(map, false);
    }

}
